package de.szut.traineeslife.adapter;

import java.util.ArrayList;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.actionbarsherlock.app.SherlockFragment;
import com.viewpagerindicator.IconPagerAdapter;

import de.szut.traineeslife.R;
import de.szut.traineeslife.fragments.DayReportFragment;
import de.szut.traineeslife.fragments.ReportFragment;
import de.szut.traineeslife.utils.DateHelper;
import de.szut.traineeslife.utils.ReportsListener;

public class PagerAdapter
    extends FragmentPagerAdapter{

    private final String[] PAGER_CONTENT;
    private Fragment[] mPagerFragments;
    private DateHelper mDateHelper;
    private ReportsListener mReportsListener;

	// private static final int[] PAGER_ICONS = new int[] {
	// R.drawable.ic_launcher, R.drawable.ic_launcher,
	// R.drawable.ic_launcher, R.drawable.ic_launcher, };

    /**
     * Is the Adapter for The Reportsfragments that we use in TraineesLifeActivity
     * @param fm
     * @param pagerContent
     * @param pagerFragments
     * @param dateHelper
     * @param reportsListener
     */
    public PagerAdapter( FragmentManager fm ,String [] pagerContent,Fragment[] pagerFragments,DateHelper dateHelper,ReportsListener reportsListener) {
        super( fm );
        PAGER_CONTENT = pagerContent;
        mPagerFragments = pagerFragments;
        mReportsListener = reportsListener;
        mDateHelper = dateHelper;
    }

    @Override
    public Fragment getItem( int position ) {
//    	ArrayList<String> startDate = mDateHelper.getStartDates();
//    	ArrayList<String> endDate = mDateHelper.getEndDates();
//    	mReportsListener.setReportStartDate(startDate.get(position));
//    	mReportsListener.setReportEndDate(endDate.get(position));
    	mReportsListener.setReportTitel(PAGER_CONTENT[position]);
    	return mPagerFragments[position];
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return PAGER_CONTENT[position % PAGER_CONTENT.length];
    }

  @Override
    public int getCount() {
      return PAGER_CONTENT.length;
    }

}
